<?php
/*
 * This is inbox for sent by hospital.
 */

$in = true;
include 'all.php';
?>

<?php include '../head.php'; ?>
<title>Inbox</title>

<body>
    <div id="wrapper">

        <?php include '../header_profile.php'; ?>
        <?php include '../menu_left.php'; ?>
        <div class="salus_bank_reg float_left">


            <a class="float_left" href="http://<?= $_SERVER['HTTP_HOST'] ?>/salusme/user">
                <!--                    <div class="salus_bank_logo logo"></div>-->
                <img src="../../include/images/logo_sakusbank.png" width="104px;" height="60px;" />                
                <div class="down_arrow"></div>
            </a>

            <?php
            $getbaby = mysql_query("select * from salus_buy_product where FK_fa_user_id='" . $_COOKIE['gid'] . "' and product_id ='2'  ") or die(mysql_error());
            if (mysql_num_rows($getbaby) != 0) {
                ?>
                <a class="float_left" href="http://<?= $_SERVER['HTTP_HOST'] ?>/salusbaby" >
                    <img src="../../include/images/baby.png" width="104px;" height="50px;" />
                </a>
            <?php }
            ?>
            <div class="clear"></div>

            <div class="float_left top_menu "><a href="inbox">INBOX</a></div>



            <div class="clear"></div>




            <div class="clear"></div>
            <style>
                .bb th, .bb td{
                    border-bottom: 1px #000000 dotted !important;
                    text-align: center;
                }
            </style>



            <div id="mainContent">                                       
                <hr>
                <?php if ($_GET['sr'] == ''): ?>
                    <table width="100%" class="bb">
                        <tr>
                            <th width="30px;" >Sr.</th>
                            <th width="250px;">File Name</th>
                            <th width="225px;">Sender</th>
                            <th width="120px;">Operation</th>
                        </tr>
                        <?php
                        $i = 1;
                        $getin = mysql_query("select * from hospital_data where receiver_id = '" . $_COOKIE['vid'] . "' and flag = 0 ") or die(mysql_error());
                        while ($row = mysql_fetch_array($getin)) {
                            ?>
                            <tr>
                                <td><?= $i ?></td>
                                <td><?= $row['title'] ?></td>
                                <td><?php
                    $hos = mysql_fetch_array(mysql_query("select name from salus_hospital_list where hospital_id = '" . $row['sender_id'] . "'")) or die(mysql_error());
                    echo $hos['name'];
                            ?></td>
                                <td>
                                    <a href="inbox?sr=<?= $row['sr'] ?>">Accept</a> &nbsp; / &nbsp;
                                    <a href="inbox?den=<?= $row['sr'] ?>">Deny</a>
                                </td>
                            </tr>
                            <?php
                            $i++;
                        }
                        ?>
                    </table>     
                <?php endif; ?>
                <?php if ($_GET['sr'] != ''): ?>
                    <h3>Download File to your folder</h3>
                    <form method="post" action="../folder/moveit.php" >
                        <table>
                            <?php
                            $hos_sr = $_GET['sr'];
                            $get_f = mysql_query("select * from hospital_data where sr = $hos_sr") or die(mysql_error());
                            while ($row1 = mysql_fetch_array($get_f)) {
                                $document = $row1['document'];
                                ?>
                                <tr>
                                    <td>File Name :</td>
                                    <td><?= $row1['title'] ?>
                                        <input type="hidden" name="hos_file_id" value="<?= $row1['sr'] ?>" />
                                        <input type="hidden" name="file" value="<?= $row1['title'] ?>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>Select Folder :</td>
                                    <td>
                                        <select name="folder_id">
                                            <?php
                                            $fols = mysql_query("select * from me_folders where uid = '" . $_COOKIE['vid'] . "' ") or die(mysql_error());
                                            while ($row2 = mysql_fetch_array($fols)) {
                                                ?>
                                                <option value="<?= $row2['sr'] ?>"><?= $row2['folder'] ?></option>
                                            <?php }
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input type="hidden" name="document" value="<?= $document ?>" />
                                        <input type="submit" value="Download Folder" style="height: 35px; width: 125px;" />
                                    </td>
                                    <td></td>
                                </tr>
                            <?php } ?>
                        </table>
                    </form>

                <?php endif; ?>

                <?php
                if ($_GET['den'] != '') {
                    $hos_sr = $_GET['den'];
                    mysql_query("update hospital_data set flag = 2 where sr = $hos_sr ") or die(mysql_error());
                    header('Location:inbox');
                }
                ?>


            </div>

        </div><!-- wrapper over    -->
        <?php
        include '../../include/config.php';
        include '../menu_right.php';
        ?>

</body>
</html>